using System;
using System.Collections.Generic;
using System.Text;
using Entites;
using Utility;
using DAL;

namespace BUS
{
   public class TinhTrangBUS
    {
         public static void Insert(TinhTrang tt)
        {
            TinhTrangDAL ttDAL = new TinhTrangDAL();
            ttDAL.Insert(tt);
        }
        public static void Update(TinhTrang tt)
        {
            TinhTrangDAL ttDAL = new TinhTrangDAL();
            ttDAL.Update(tt);
        }
        public static void Delete(int iD)
        {
            TinhTrangDAL ttDAL = new TinhTrangDAL();
            ttDAL.Delete(iD);
        }
        public static tbTinhTrangCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            TinhTrangDAL ttDAL = new TinhTrangDAL();
            return ttDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbTinhTrangCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            TinhTrangDAL ttDAL = new TinhTrangDAL();
            return ttDAL.Get(cri.Criter, 0, 0, tbTinhTrangColumns.MaTinhTrang.ToString(), OrderDirection.ASC.ToString(), out total);
        }
       public static TinhTrang GetByID(int iD)
       {
           int total = 0;
           Criteria cri = new Criteria();
           cri.add(Condition.AND, tbTinhTrangColumns.MaTinhTrang.ToString(), Condition.EQUAL, iD);
           TinhTrangDAL ttDAL = new TinhTrangDAL();
           tbTinhTrangCollection tinhtrangcollection = ttDAL.Get(cri.Criter,
                 0, 0, tbTinhTrangColumns.MaTinhTrang.ToString(), OrderDirection.ASC.ToString(), out total);
           if (tinhtrangcollection.Count > 0)
               return tinhtrangcollection[0];
           return null;
       }
      
        public static tbTinhTrangCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            TinhTrangDAL ttDAL = new TinhTrangDAL();
            return ttDAL.Get(cri.Criter, 1, number,
             tbTinhTrangColumns.MaTinhTrang.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbTinhTrangCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            TinhTrangDAL ttDAL = new TinhTrangDAL();
            return ttDAL.Get(cri.Criter, 1, number,
               tbTinhTrangColumns.MaTinhTrang.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
    

}
